<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\MaterialBillRep;
use Illuminate\Http\Request;

class MaterialBill extends Controller
{
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new MaterialBillRep();
    }

    /**
     * 获取物料清单表
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function getMaterialBillList(Request $request)
    {
        $params = $request->only([]);
        $data = $this->rep->getMaterialBillListRep($params);
        return re(0,$data,'success');
    }

    public function createMaterialBill(Request $request){
        $params = $request->only(['id','product_id','name','model_number_id','specification_id','color_id','dosage_arr']);
        $data = $this->rep->createMaterialBillRep($params);
        return re(0,$data,'success');
    }

    public function updateMaterialBillChild(Request $request){
        $params = $request->only(['bill_child_id','dosage']);
        $data = $this->rep->updateMaterialBillChildRep($params);
        return re(0,$data,'success');
    }

    public function delMaterialBillChild(Request $request){
        $params = $request->only(['bill_child_id']);
        $data = $this->rep->delMaterialBillChildRep($params);
        return re(0,$data,'success');
    }

}
